/*
 * platform.h
 *
 *  Created on: Aug 5, 2019
 *      Author: duan
 */

#ifndef PLATFORM_H_
#define PLATFORM_H_

#include "xparameters.h"

/* Comment the following line, if you want a smaller and faster bootloader which will be silent */

#define XPAR_RS232_UART_BASEADDR   XPAR_UARTLITE_0_BASEADDR
#define XPAR_RS232_DEVICE_ID       XPAR_UARTLITE_0_DEVICE_ID
#define XPAR_AXI_INTC_0_RS232_INTERRUPT_INTR  XPAR_AXI_INTC_0_AXI_UARTLITE_0_INTERRUPT_INTR
#define XPAR_RS232_INTERRUPT_MASK  XPAR_AXI_UARTLITE_0_INTERRUPT_MASK

#define rXNS_DELAY      (*(volatile unsigned int *)(XPAR_FUSION_CTRL_0_S_AXI_RNG00_BASEADDR + 44)) //;
#define udelay(x)       rXNS_DELAY = x*100; while(rXNS_DELAY > 0)

#define BUF_SIZE  64

typedef struct{
	volatile unsigned int fetch_count;
	volatile unsigned int receive_count;
	unsigned char receive_buffer[BUF_SIZE];
	void (* send_byte)(unsigned char data);
} UART_T;

extern UART_T uart;

void XUartLite_Putc(unsigned char data);
void platform_init();

#endif /* PLATFORM_H_ */
